import React, { Component } from "react";

export default class App extends Component {
    state = {
        proList: []
    }
    // 生命周期函数相当于Vue的mounted函数
    componentDidMount() {
        fetch('http://121.89.205.189/api/pro/list?limitNum=20')
            .then(res => res.json())
            .then(res => {
                console.log(res)
                this.setState({
                    proList: res.data
                })
            })
    }
    render() {
        const { proList } = this.state
        return (
            <div>
                {
                    proList && proList.map(item => {
                        return (
                            <div key={item.proid}>{item.proname}</div>
                        )
                    })
                }
            </div>
        )
    }
}